#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int a[105], fac[10500];
	int min = 32768;
	int tmp, n = 0, top = 0;
	while (scanf("%d", &tmp))
	{
		if (tmp == 0) break;
		else a[n++] = tmp;
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] < min) min = a[i];
	}
	for (int i = 1; i <= min; i++)
	{
		if (min % i == 0)
		{
			fac[top++] = i;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < top; j++)
		{
			if (fac[j]!=0 && a[i] % fac[j] != 0)
			{
				fac[j] = 0;
			}
		}
	}
	for (int i = top - 1; i >= 0; i--)
	{
		if (fac[i] != 0)
		{
			printf("%d", fac[i]);
			break;
		}
	}
	for (int i = 0; i < n; i++)
	{
		printf(" %d", a[i]);
	}
	return 0;
}